<?php 
/**
 * @author Douglas Caina
 * codigo que ajuda na hora de importar html baseado no template definido no config
 * **/
class Template {

	public $template_folder;
	public $template_name;
	public $upload_folder = "_resources/upload";
	public $scripts_to_load;
	
	var $template;

	/**
	 * A configuracao e feita no confing, nao aqui.*/
	function __construct(){
		$instance =&get_instance();
		$this->template_folder = $instance->config->item('template_folder');
		$this->template_name = $instance->config->item('template_name');
		$this->upload_folder = $instance->config->item("upload_folder");
		$this->scripts_to_load = $instance->config->item("load_scripts");
	} 	
	
	//beta?
	static public function getInstance(){
		if(!isset(self::$template)){
			$class = __CLASS__;
			self::$template = new $class;
		}
		return self::$template;
	}
	
	function get_template_path(){
		return $this->template_folder."/templates/".$this->template_name;
	}
	function get_image($image_name){
		return base_url(self::get_template_path()."/images/".$image_name);
	}
	function get_script($script_name){
		return base_url(self::get_template_path()."/js/".$script_name);
	}
	function get_css($css_name){
		return base_url(self::get_template_path()."/css/".$css_name);
	}
	
	function get_all_scripts(){
		$scritps = "";	
		foreach ($this->scripts_to_load as $script) {
			$src = self::get_script($script);
			$scritps .= "<script type='text/javascript' src='{$src}'></script>";
		}
		return $scritps;
	}
	
	
	
}

?>